<template>
	<div>
		<el-dialog :title="$t('action.add')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_short_code')" prop="short_code">
							<el-input v-model="form.short_code" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_short_code')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_code')" prop="code">
							<el-input v-model="form.code" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_code')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_name')" prop="name">
							<el-input v-model="form.name" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_name')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_pinyin')" prop="pinyin">
							<el-input v-model="form.pinyin" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_pinyin')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_industry')" prop="industry">
							<el-input v-model="form.industry" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_industry')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_region')" prop="region">
							<el-input v-model="form.region" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_region')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_state')" prop="state">
							<el-input v-model="form.state" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_state')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_concept')" prop="concept">
							<el-input v-model="form.concept" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_concept')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_bourse')" prop="bourse">
							<el-input v-model="form.bourse" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_bourse')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_stop')" prop="stop">
							<el-switch :active-value="0" :inactive-value="1" v-model="form.stop"></el-switch>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_close')" prop="close">
							<el-switch :active-value="0" :inactive-value="1" v-model="form.close"></el-switch>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_buy_up')" prop="buy_up">
							<el-input v-model="form.buy_up" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_buy_up')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_buy_down')" prop="buy_down">
							<el-input v-model="form.buy_down" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_buy_down')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
				   <el-col :span="24">
                        <el-form-item :label="$t('field.Stock_status')" prop="status">
                            <el-select style="width:100%" v-model="form.status" :size="size" clearable filterable :placeholder="$t('system.pleaseSelect')">
                                <el-option key="0"  label="正常" :value="1"></el-option>
                                <el-option key="1"  label="删除" :value="0"></el-option>
                            </el-select>
                        </el-form-item>
                   </el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_type')" prop="type">
							<el-input v-model="form.type" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_type')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_buy')" prop="buy">
							<el-input v-model="form.buy" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_buy')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_sell')" prop="sell">
							<el-input v-model="form.sell" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_sell')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_trade')" prop="trade">
							<el-switch :active-value="1" :inactive-value="0" v-model="form.trade"></el-switch>
						</el-form-item>
					</el-col>
				 </el-row>
	 	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_stop_time')" prop="stop_time">
							<el-date-picker type="date"   v-model="form.stop_time" clearable :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_stop_time')})"></el-date-picker>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_lastamount')" prop="lastamount">
							<el-input v-model="form.lastamount" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_lastamount')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_lastvolumn')" prop="lastvolumn">
							<el-input v-model="form.lastvolumn" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_lastvolumn')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_control_ratio')" prop="control_ratio">
							<el-input v-model="form.control_ratio" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_control_ratio')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_control_amount')" prop="control_amount">
							<el-input v-model="form.control_amount" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_control_amount')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_control_remaining')" prop="control_remaining">
							<el-input v-model="form.control_remaining" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_control_remaining')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_pclose')" prop="pclose">
							<el-input v-model="form.pclose" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_pclose')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_stock_value')" prop="stock_value">
							<el-input v-model="form.stock_value" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_stock_value')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_enable_time')" prop="enable_time">
							<el-date-picker type="date"   v-model="form.enable_time" clearable :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_enable_time')})"></el-date-picker>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_stock_value_market')" prop="stock_value_market">
							<el-input v-model="form.stock_value_market" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_stock_value_market')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Stock_first_acquisition_time')" prop="first_acquisition_time">
							<el-date-picker type="date"   v-model="form.first_acquisition_time" clearable :placeholder="$t('system.pleaseInput',{title:$t('field.Stock_first_acquisition_time')})"></el-date-picker>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { add } from '@/api/app/stock'



export default {
	name:'stockadd',
	components: {
	   	   
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		querys:{
			type:Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			
			form: {
			   short_code:'',
			   code:'',
			   name:'',
			   pinyin:'',
			   industry:'',
			   region:'',
			   state:'',
			   concept:'',
			   bourse:'',
			   stop:'',
			   close:'',
			   buy_up:'',
			   buy_down:'',
			   status:1,
			   type:'',
			   buy:'',
			   sell:'',
			   trade:'',
			   create_time:'',
			   stop_time:'',
			   lastamount:'',
			   lastvolumn:'',
			   control_ratio:'',
			   control_amount:'',
			   control_remaining:'',
			   pclose:'',
			   stock_value:'',
			   enable_time:'',
			   stock_value_market:'',
			   first_acquisition_time:'',
			},
		    initial:{},   
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
		  if(this.querys){
		  }
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					add(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss'
</style>
